package com.go.manaservice.controller;


import com.go.manaservice.entity.result.BusAdminRes;
import com.go.manaservice.entity.vo.BusAdminQuery;
import com.go.manaservice.service.AdminService;
import com.go.serviceutils.JwtUtils;
import com.go.serviceutils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author ZhengYuXiang
 * @version 1.0
 * @date 2021/12/26 10:11 下午
 */
@CrossOrigin
@Api(description="登录api")
@RestController
@RequestMapping("/api")
public class LoginController {
    @Autowired
    private AdminService adminService;

    @ApiOperation(value = "登录")
    @PostMapping("login")
    public R adminLogin(@ApiParam(value = "查询对象条件")
                            @RequestBody BusAdminQuery busAdminQuery){

        System.out.println(busAdminQuery);
        BusAdminRes loginAdminRes = adminService.login(busAdminQuery);
//        JwtUtils.getJwtToken()
        return R.ok().data("token",loginAdminRes);
    }
    //info
    @GetMapping("info")
    public R info(){

        return R.ok().data("roles","[admin]").data("name","admin").data("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
    }
}

